package com.zby.ss.core.builder;

import com.zby.ss.core.factoryimpl.FileFactoryImpl;
import com.zby.ss.core.facotry.FileFactory;
import com.zby.ss.core.facotry.ObjectFactory;
import com.zby.ss.core.factoryimpl.ObjectFactoryImpl;

/**
 * Created By zby on 15:25 2019/2/16
 */

public class FactoryBuilder {

    private volatile static FileFactory fileFactory;

    private volatile static ObjectFactory objectFactory;

    private FactoryBuilder() {

    }


    /**
     * Created By zby on 15:19 2019/2/16
     * 实例化对象
     */
    public static synchronized FileFactory createFileFactory() {
        if (fileFactory == null) {
            fileFactory = new FileFactoryImpl();
        }
        return fileFactory;
    }

    /**
     * Created By zby on 15:19 2019/2/16
     * 实例化对象工厂
     */
    public static synchronized ObjectFactory createObjectFactory() {
        if (objectFactory == null) {
            objectFactory = new ObjectFactoryImpl();
        }
        return objectFactory;
    }
}
